package com.mdd.front.validate.users;

import com.mdd.common.validator.annotation.StringContains;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

@Data
@ApiModel("绑定手机参数")
public class UserBindValidate implements Serializable {

    private static final long serialVersionUID = 1L;

    @NotNull(message = "type参数缺失")
    @StringContains(values = {"bind", "change"})
    @ApiModelProperty(value = "操作类型", required = true, example = "bind=绑定,change=修改")
    private String type;


    @NotNull(message = "realName参数缺失")
    @NotEmpty(message = "真实姓名不能为空")
    @ApiModelProperty(value = "真实姓名", required = true)
    private String realName;

    @NotNull(message = "mobile参数缺失")
    @NotEmpty(message = "手机号不能为空")
    @Length(min = 11, max = 11, message = "手机号只能为11位")
    @ApiModelProperty(value = "手机号", required = true)
    private String mobile;


    @NotNull(message = "cardNo参数缺失")
    @NotEmpty(message = "身份证号码不能为空")
    @Length(min = 18, max = 18, message = "身份证号只能为18位")
    @Pattern(regexp = "^\\d{6}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "身份证号码有误")
    @ApiModelProperty(value = "身份证号码", required = true)
    private String cardNo;


    @NotNull(message = "code参数缺失")
    @NotEmpty(message = "验证码不能为空")
    @ApiModelProperty(value = "验证码", required = true)
    private String code;

}
